package com.zhf.demo02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: ZhaoHuanfeng
 * @Date: 2020/10/12 22:29
 */
@WebServlet(name = "HelloServlet4" , urlPatterns = "/hello4")
public class HelloServlet4 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("调用post方法");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("调用get方法");
    }

/*    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("使用注解真好");
        String method = req.getMethod();
        System.out.println("获取到的请求方式为："+method);
        if (method.equalsIgnoreCase("get")){
            doGet(req, resp);
        }
        if (method.equalsIgnoreCase("post")){
            doPost(req, resp);
        }
    }*/
}
